package demoMod.moduploader;

import com.badlogic.gdx.Files;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import demoMod.moduploader.core.MainWindow;
import org.apache.logging.log4j.util.PropertiesUtil;

import java.lang.reflect.Field;
import java.util.Map;

public class DesktopLauncher {
    public static void main(String[] args) {
        try {
            Field environmentField = PropertiesUtil.class.getDeclaredField("environment");
            environmentField.setAccessible(true);
            Object environment = environmentField.get(PropertiesUtil.getProperties());
            Class environmentCls = Class.forName("org.apache.logging.log4j.util.PropertiesUtil$Environment");
            Field literalField = environmentCls.getDeclaredField("literal");
            literalField.setAccessible(true);
            Map<String, String> literal = (Map<String, String>) literalField.get(environment);
            literal.put("log4j2.loggerContextFactory", "org.apache.logging.log4j.core.impl.Log4jContextFactory");
        } catch (IllegalAccessException | NoSuchFieldException | ClassNotFoundException e) {
            e.printStackTrace();
        }
        LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
        config.backgroundFPS = 60;
        config.foregroundFPS = 60;
        config.fullscreen = false;
        config.width = 1280;
        config.height = 960;
        config.resizable = false;
        config.title = "STS Mod Uploader";
        config.addIcon("icon.png", Files.FileType.Internal);

        new LwjglApplication(new MainWindow(), config);
    }
}
